package org.effectivejava.examples.chapter02.item03.field;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class Test {

    /**
     * 成功攻击单例
     */
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Elvis elvis = Elvis.INSTANCE;
        System.out.println(elvis);
        Constructor<Elvis> declaredConstructor = Elvis.class.getDeclaredConstructor();
        declaredConstructor.setAccessible(true);
        Elvis elvis2 = declaredConstructor.newInstance();
        System.out.println(elvis2);
    }
}
